home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 60.zip
/
BS1 part 60
/
Imagemaster d5.adf
/
piarc.lzh.parta
/
gif.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-04-14
|
5KB
|
208 lines
/* ARexx GIF */
parse arg var1
/*
* GIF.rexx - GIF image load
*
* If you encounter a .GIF file we do not read, sent it to us (we suggest
* you use the Black Belt Bulletin Board at 1-406-367 2227) with an
* explanation and we will endeavor to extend our loader to handle it.
*
* Written by: Black Belt Systems Technical Development
* Last Update: March 25th, 1993
* Revision: 1.01
* For: Black Belt Systems image processing series IM, IM F/c, and IP.
*
* Modifications:
* 1.01 25 Mar 1993 (BC) Did not report on insufficient memory for
* new buffer from IM prior to 9.51
* 1.00 25 Feb 1993 (BC) Replaces loader inside IM.
* More robust.
* Streamlined calling procedure.
*
*/
call pragma('stack',20000);
/*
* open rexxsupport.library -- needed for some functions
*/
if ~show('L',"rexxsupport.library") then do
if addlib('rexxsupport.library',0,-30,0) then do
/* everything's ok */
end;
else do
say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
say 'Cannot operate script without this library - sorry!';
exit 10;
end;
end;
prtnme = 'IM_Port';
cmdpath = 'cmpi:';
/*
* Get the file name parts
*/
prevpath = 'ram:';
if show('C',rawpath) = 1 then do
prevpath = getclip(rawpath);
end;
prevname = 'image';
if show('C',rawname) = 1 then do
prevname = getclip(rawname);
end;
prevext = '.GIF';
if show('C',rawext) = 1 then do
prevext = getclip(rawext);
end;
address(prtnme);
'autoredraw 0';
if var1 = 'load' then do
loadquestion = 0
end
else if var1 = 'save' then do
loadquestion = 1
end
else do
options results;
'gadgets "Load .GIF","Image","Save .GIF","Image"';
loadquestion = result-1;
options;
end
if loadquestion < 0 then do
address(prtnme);
'tofront';
exit 0;
end
if loadquestion = 0 then do
options results;
'filerequest "'||prevpath||'" "'||prevname||'" "'||prevext||'" '||'"Load .GIF"';
GIFfile = result;
options;
call checkfile(GIFfile);
end
if loadquestion = 1 then do
options results;
'filerequest "'||prevpath||'" "'||prevname||'" "'||prevext||'" '||'"Save .GIF"';
GIFfile = result;
options;
call checkfile(GIFfile);
/* Could put compression question Here !! */
end
options results;
'jackin';
jack = result;
options;
address command cmdpath||'GIF '||jack||' '||loadquestion||' "'||GIFfile||'" '||prevname||' '||compression;
address(prtnme);
'autoredraw 1';
exit 0;
checkfile:
arg thefile;
if thefile = 'FR_CANCELLED' then do
address(prtnme);
'tofront';
exit 0;
end;
prevpath = gimmepath(thefile);
call setclip(rawpath,prevpath);
prevname = gimmename(thefile);
call setclip(rawname,prevname);
prevext = gimmeext(thefile);
call setclip(rawext,prevext);
return;
end
/*
* gimmepath
*
* This takes the provided argument and sucks the path out of it, then
* returns that path to the caller, sans file name.
*/
gimmepath:
arg fullnamegx;
tempgx = reverse(fullnamegx);
lengx = length(fullnamegx); /* get length of string */
slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
colondex = index(tempgx,':'); /* first occurance of ':' from right */
seploc = 0; /* assumes current dir, no path supplied */
if slashdex ~= 0 then do /* we assume we are in a DIR */
seploc = (lengx - slashdex)+1;
end;
else do
if colondex ~= 0 then do /* we assume we are on a device */
seploc = (lengx - colondex)+1;
end;
end;
gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
gxpath = left(fullnamegx,seploc);
return(gxpath);
end
gimmename:
arg fullnamegx;
tempgx = reverse(fullnamegx);
lengx = length(fullnamegx); /* get length of string */
slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
colondex = index(tempgx,':'); /* first occurance of ':' from right */
seploc = 0; /* assumes current dir, no path supplied */
if slashdex ~= 0 then do /* we assume we are in a DIR */
seploc = (lengx - slashdex)+1;
end;
else do
if colondex ~= 0 then do /* we assume we are on a device */
seploc = (lengx - colondex)+1;
end;
end;
extpos = lastpos(".",fullnamegx) - 2;
if extpos > seploc then do
gxname = substr(fullnamegx,seploc+1,extpos-seploc+1);
end;
else do
gxname = substr(fullnamegx,seploc+1);
end;
return(gxname);
end
gimmeext:
arg fullnamegx;
tempgx = reverse(fullnamegx);
lengx = length(fullnamegx); /* get length of string */
slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
colondex = index(tempgx,':'); /* first occurance of ':' from right */
seploc = 0; /* assumes current dir, no path supplied */
if slashdex ~= 0 then do /* we assume we are in a DIR */
seploc = (lengx - slashdex)+1;
end;
else do
if colondex ~= 0 then do /* we assume we are on a device */
seploc = (lengx - colondex)+1;
end;
end;
extpos = lastpos(fullnamegx,'.');
if extpos > seploc then do
gxext = substr(fullnamegx,extpos+1);
end
else do
gxext = '';
end
return(gxext);
end